<?php
/*********************************************************************************
 * Copyright (C) 2011-2013 X2Engine Inc. All Rights Reserved.
 * 
 * X2Engine Inc.
 * P.O. Box 66752
 * Scotts Valley, California 95067 USA
 * 
 * Company website: http://www.x2engine.com 
 * Community and support website: http://www.x2community.com 
 * 
 * X2Engine Inc. grants you a perpetual, non-exclusive, non-transferable license 
 * to install and use this Software for your internal business purposes.  
 * You shall not modify, distribute, license or sublicense the Software.
 * Title, ownership, and all intellectual property rights in the Software belong 
 * exclusively to X2Engine.
 * 
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EITHER 
 * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT.
 ********************************************************************************/

/* @edition:pro */

/**
 * This is the model class for table "x2_reports".
 *
 * The followings are the available columns in table 'x2_reports':
 * @property integer $id
 * @property string $field1
 * @property string $field2
 * @property string $start
 * @property string $end
 * @property string $range
 * @property string $cellType
 * @property string $cellData
 * @property integer $zero
 * @property string $createDate
 * @property string $createdBy
 * @property string $parameters
 */
class Reports extends CActiveRecord
{
	public $rowPie;

	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Reports the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'x2_reports';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zero', 'numerical', 'integerOnly'=>true),
			array('field1, field2, dateRange, cellType, cellData, createdBy', 'length', 'max'=>250),
			array('start, end, createDate', 'length', 'max'=>20),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, field1, parameters, field2, start, end, dateRange, cellType, cellData, zero, createDate, createdBy, rowPie', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'field1' => 'Field1',
			'field2' => 'Field2',
			'start' => 'Start',
			'end' => 'End',
			'dateRange' => 'Date Range',
			'cellType' => 'Cell Type',
			'cellData' => 'Cell Data',
			'zero' => 'Zero',
			'createDate' => 'Create Date',
			'createdBy' => 'Created By',
			'rowPie'=>'',
            'parameters' => 'Parameters',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('field1',$this->field1,true);
		$criteria->compare('field2',$this->field2,true);
		$criteria->compare('start',$this->start,true);
		$criteria->compare('end',$this->end,true);
		$criteria->compare('dateRange',$this->range,true);
		$criteria->compare('cellType',$this->cellType,true);
		$criteria->compare('cellData',$this->cellData,true);
		$criteria->compare('zero',$this->zero);
		$criteria->compare('createDate',$this->createDate,true);
		$criteria->compare('createdBy',$this->createdBy,true);
        $criteria->compare('parameters',$this->parameters,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}
